package com.design.pattern.adapter.objectAdapter;

import com.design.pattern.adapter.classAdapter.Adaptee;
import com.design.pattern.adapter.classAdapter.Target;

/**
 * Created by Administrator on 2016/5/17.
 */
public class ObjectAdapter {
    /**
     * 对象适配器模式，在适配器内部管理适配者的对象
     */
    static class Adapter implements Target{
        //直接关联被适配的类
        private Adaptee adaptee;

        public Adapter(Adaptee adaptee){
            this.adaptee = adaptee;
        }
        @Override
        public void request() {
            if (this.adaptee != null){
                this.adaptee.doSomthingSpecial();
            }
        }
    }

    public static void main(String[] args) {
        Target target = new Adapter(new Adaptee());
        target.request();
    }

}
